import { Constants } from '../constants'
import { DataTypes, Sequelize } from 'sequelize'
import { BaseModel, BaseModelAttribute } from './baseModel'
import { ModelUtils } from './modelUtils'
interface LiabilitiesAttribute extends BaseModelAttribute {
  creditor: string
  amount: number
  estimatedRepaymentDate: Date
  actualRepaymentDate: Date
  date: Date
}
export class Liabilities extends BaseModel<LiabilitiesAttribute>{
  creditor: string
  amount: number
  estimatedRepaymentDate: Date
  actualRepaymentDate: Date
  date: Date
}
export class LiabilitiesInit {
  static init(sequelizeInstance: Sequelize) {
    Liabilities.init(ModelUtils.appendPublicFields({
      creditor: { type: DataTypes.STRING, allowNull: false, comment: '债权人' },
      amount: { type: DataTypes.DECIMAL, allowNull: false, comment: Constants.amount },
      estimatedRepaymentDate: { type: DataTypes.DATE, allowNull: true, comment: '预计还款日期' },
      actualRepaymentDate: { type: DataTypes.DATE, allowNull: true, comment: '实际还款日期' },
      date: { type: DataTypes.DATE, allowNull: false, comment: Constants.date }
    }), ModelUtils.appendTablePublicProperties('liabilities', sequelizeInstance, '负债表'))
  }
}